<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<style type="text/css">
			*{
				padding: 0;
				margin: 0;
			}
			#box{
				width: 250px;
				height: 250px;
				background: red;
				margin: 40px;
				position: relative;
			}
			#small{
				width: 50px;
				height: 50px;
				background: yellow;
				position: absolute;
				top: 60px;
				left: 60px;
			}
		</style>
		<script type="text/javascript">
			window.onload  = function(){
				var box = document.getElementById("box");
				var small = document.getElementById("small");
				//如果是有定位属性的元素，获得的直接是它的left和top
				//获得有定位属性元素的left和top值
				var left = small.offsetLeft;
				var top = small.offsetTop;
				alert(top);
			}
		</script>
	</head>
	<body>
		<div id="box">
			<div id="small"></div>
		</div>
	</body>
</html>
